package org.example.petsystem.service.impl;

import org.example.petsystem.entity.ResultBody;
import org.example.petsystem.mapper.ChatMapper;
import org.example.petsystem.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class ChatServiceimpl implements ChatService {
    @Autowired
    private ChatMapper chatMapper;
    @Override
    public ResultBody addChatU(Map<String, Object> map) {
        if(chatMapper.addChatU(map)>0)
        {
            return new ResultBody(200,"添加成功",true);
        }
        else
            return new ResultBody(400,"添加失败",false);
    }
    @Override
    public ResultBody displayChat() {
        if(!chatMapper.displayChat().isEmpty())
        {
            return new ResultBody(200,"添加成功",chatMapper.displayChat(),chatMapper.displayChat().size());
        }
        else if (chatMapper.displayChat().isEmpty())
        {
            return new ResultBody(200,"暂时未有聊天记录",chatMapper.displayChat());
        }
        else
            return new ResultBody(400,"添加失败",false);
    }

}
